#!/usr/bin/perl
use strict;

package nshelp;
sub nshelp {
    my $nsnum = shift;
    my $nsnick = shift;
    my $VER = shift;
    my $NETWORK = shift;
    my $remote = shift;
    my $input = shift;
    if ($$input[4] eq "") {
    print $remote "$nsnum O $$input[0] :\026$nsnick - NickName Services      $VER\n";
    print $remote "$nsnum O $$input[0] :=========================================\n";
    print $remote "$nsnum O $$input[0] :$nsnick is $NETWORK\'s NickName Services Bot.\n";
    print $remote "$nsnum O $$input[0] : \n";
    print $remote "$nsnum O $$input[0] :Commands are : REGISTER  MYINFO  INFO  WHOIS  RECOVER  NEWPASS  IDENTIFY UNREGISTER\n";

    print $remote "$nsnum O $$input[0] : \n";
    print $remote "$nsnum O $$input[0] :=========================================\n";
}
    else {
	$$input[4] = lc($$input[4]);
	if (!(-e "./help/ns/$$input[4].txt")) {
	    print $remote "$nsnum O $$input[0] :No such help command.\n";
	}
	else {
	    print $remote "$nsnum O $$input[0] :\026$nsnick - NickName Services      $VER\n";
	    open (FH, "./help/ns/$$input[4].txt"); my @HELP = <FH>; close FH;
	    foreach my $i (@HELP) {
		chomp $i;
		my $bold = "\002";
		my $newspace = " ";
		$i =~ s/%n%/$newspace/g;
		$i =~ s/%ns%/$nsnick/g;
		$i =~ s/%X%/$nsnick/g;
		$i =~ s/%b%/$bold/g;
		$i =~ s/%NET%/$NETWORK/g;
		print $remote "$nsnum O $$input[0] :$i\n";
	    }
	    undef @HELP;
	}
    }
}


1;
